﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;

namespace lcmyjobs.Web.users
{
    public partial class JobList : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.Title = string.Format("人管理中心—职位搜索：职位搜索   {0}", Application["webname"].ToString());
                if (Application["webid"] != null)
                {
                    //BindIsFrist(Convert.ToInt32(Application["webid"]));
                    Bind(Convert.ToInt32(Application["webid"]));

                    if (Session["user_name"] != null)
                    {
                        this.lblName.Text = Session["user_name"].ToString();
                    }

                }
            }

        }





        private void Bind(int atid)
        {
            //string workerclass = Request["workerclass"];
            //string jobsname = Request["jobsname"];
            //string areaname = Request["areaname"];
            //string tradename = Request["tradename"];
            //string salary = Request["salary"];
            //string edu = Request["edu"];
            //string exp = Request["exp"];
            //string majorname = Request["majorname"];
            //string lan = Request["lan"];
            //string level = Request["level"];
            //string releasetime = Request["releasetime"];

            //lcmyjobs.Model.searchjobs sj = new Model.searchjobs();

            //sj.workerclass = Convert.ToInt32(workerclass);
            //sj.workexp_id = Convert.ToInt32(exp);
            //sj.edus_id = Convert.ToInt32(edu);
            //sj.languages_id = Convert.ToInt32(lan);
            //sj.languages_level = Convert.ToInt32(level);
            //sj.salarym = Convert.ToInt32(salary);

            //if (!string.IsNullOrEmpty(releasetime))
            //{
            //    sj.releasetime = Convert.ToDateTime(releasetime);
            //}

            //if (!string.IsNullOrEmpty(areaname))
            //{
            //    string[] areas = areaname.Split(',');
            //    if (areas.Length == 1)
            //    {
            //        sj.area_name1 = areas[0];
            //    }
            //    if (areas.Length == 2)
            //    {
            //        sj.area_name1 = areas[0];
            //        sj.area_name2 = areas[1];
            //    }
            //    if (areas.Length == 3)
            //    {
            //        sj.area_name1 = areas[0];
            //        sj.area_name2 = areas[1];
            //        sj.area_name3 = areas[2];
            //    }
            //}

            //if (!string.IsNullOrEmpty(jobsname))
            //{
            //    string[] jobs = jobsname.Split(',');
            //    if (jobs.Length == 1)
            //    {
            //        sj.job_name1 = jobs[0];
            //    }
            //    if (jobs.Length == 2)
            //    {
            //        sj.job_name1 = jobs[0];
            //        sj.job_name2 = jobs[1];
            //    }
            //    if (jobs.Length == 3)
            //    {
            //        sj.job_name1 = jobs[0];
            //        sj.job_name2 = jobs[1];
            //        sj.job_name3 = jobs[2];
            //    }
            //}

            //if (!string.IsNullOrEmpty(majorname))
            //{
            //    string[] majors = majorname.Split(',');

            //    if (majors.Length == 1)
            //    {
            //        sj.major_name1 = majors[0];
            //    }
            //    if (majors.Length == 2)
            //    {
            //        sj.major_name1 = majors[0];
            //        sj.major_name2 = majors[1];
            //    }
            //    if (majors.Length == 3)
            //    {
            //        sj.major_name1 = majors[0];
            //        sj.major_name2 = majors[1];
            //        sj.major_name3 = majors[2];
            //    }
            //}
            //if (!string.IsNullOrEmpty(tradename))
            //{
            //    string[] trades = tradename.Split(',');


            //    if (trades.Length == 1)
            //    {
            //        sj.tradename1 = trades[0];
            //    }
            //    if (trades.Length == 2)
            //    {
            //        sj.tradename1 = trades[0];
            //        sj.tradename2 = trades[1];
            //    }
            //    if (trades.Length == 3)
            //    {
            //        sj.tradename1 = trades[0];
            //        sj.tradename2 = trades[1];
            //        sj.tradename3 = trades[2];
            //    }

            //}

            //int count = 0;

            //DataSet ds = new lcmyjobs.BLL.enterprise_releasejob().GetSearch(sj,atid, this.AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize, out count);

            //this.AspNetPager1.RecordCount = count;


            //this.GridView1.DataSource = ds;
            //this.GridView1.DataBind();

            string workerclass = Request["workerclass"];
            string jobsname = Request["jobsname"];
            string areaname = Request["areaname"];
            string tradename = Request["tradename"];
            string salary = Request["salary"];
            string edu = Request["edu"];
            string exp = Request["exp"];
            string majorname = Request["majorname"];
            string lan = Request["lan"];
            string level = Request["level"];
            string releasetime = Request["releasetime"];
            string key_words = Request["key_words"];

            lcmyjobs.Model.searchjobs sj = new Model.searchjobs();

            sj.workerclass = Convert.ToInt32(workerclass);
            sj.workexp_id = Convert.ToInt32(exp);
            sj.edus_id = Convert.ToInt32(edu);
            sj.languages_id = Convert.ToInt32(lan);
            sj.languages_level = Convert.ToInt32(level);
            sj.salarym = Convert.ToInt32(salary);
            sj.key_words = key_words;//关键字

            //if (!string.IsNullOrEmpty(releasetime))
            //{
            //    sj.releasetime = Convert.ToDateTime(releasetime);
            //}

            sj.releasetime = Convert.ToInt32(releasetime);

            if (!string.IsNullOrEmpty(areaname))
            {
                string[] areas = areaname.Split(',');
                if (areas.Length == 1)
                {
                    sj.area_name1 = areas[0];

                    string[] t_area = areas[0].Split('•');
                    if (t_area.Length > 0)
                    {
                        sj.area_name4 = t_area[0];
                    }
                }
                if (areas.Length == 2)
                {
                    sj.area_name1 = areas[0];
                    sj.area_name2 = areas[1];

                    string[] t_area = areas[0].Split('•');
                    if (t_area.Length > 0)
                    {
                        sj.area_name4 = t_area[0];
                    }

                    string[] t_area1 = areas[1].Split('•');
                    if (t_area.Length > 0)
                    {
                        sj.area_name5 = t_area1[0];
                    }
                }
                if (areas.Length == 3)
                {
                    sj.area_name1 = areas[0];
                    sj.area_name2 = areas[1];
                    sj.area_name3 = areas[2];


                    string[] t_area = areas[0].Split('•');
                    if (t_area.Length > 0)
                    {
                        sj.area_name4 = t_area[0];
                    }

                    string[] t_area1 = areas[1].Split('•');
                    if (t_area.Length > 0)
                    {
                        sj.area_name5 = t_area1[0];
                    }

                    string[] t_area2 = areas[2].Split('•');
                    if (t_area.Length > 0)
                    {
                        sj.area_name6 = t_area2[0];
                    }
                }
            }

            if (!string.IsNullOrEmpty(jobsname))
            {
                string[] jobs = jobsname.Split(',');
                if (jobs.Length == 1)
                {
                    sj.job_name1 = jobs[0];
                }
                if (jobs.Length == 2)
                {
                    sj.job_name1 = jobs[0];
                    sj.job_name2 = jobs[1];
                }
                if (jobs.Length == 3)
                {
                    sj.job_name1 = jobs[0];
                    sj.job_name2 = jobs[1];
                    sj.job_name3 = jobs[2];
                }
            }

            if (!string.IsNullOrEmpty(majorname))
            {
                string[] majors = majorname.Split(',');

                if (majors.Length == 1)
                {
                    sj.major_name1 = majors[0];
                }
                if (majors.Length == 2)
                {
                    sj.major_name1 = majors[0];
                    sj.major_name2 = majors[1];
                }
                if (majors.Length == 3)
                {
                    sj.major_name1 = majors[0];
                    sj.major_name2 = majors[1];
                    sj.major_name3 = majors[2];
                }
            }
            if (!string.IsNullOrEmpty(tradename))
            {
                string[] trades = tradename.Split(',');


                if (trades.Length == 1)
                {
                    sj.tradename1 = trades[0];
                }
                if (trades.Length == 2)
                {
                    sj.tradename1 = trades[0];
                    sj.tradename2 = trades[1];
                }
                if (trades.Length == 3)
                {
                    sj.tradename1 = trades[0];
                    sj.tradename2 = trades[1];
                    sj.tradename3 = trades[2];
                }

            }

            int count = 0;

            DataSet ds = new lcmyjobs.BLL.enterprise_releasejob().GetSearch(sj, atid, this.AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize, out count);

            this.AspNetPager1.RecordCount = count;

            if ( (ds.Tables.Count > 0) && (count > 0) )
            {
                this.GridView1.DataSource = ds;
                this.GridView1.DataBind();
                if (ds.Tables[0].Rows.Count == 0)
                {
                    this.Panel1.Visible = true;

                }
                else
                {
                    this.Panel1.Visible = false;
                }
            }
            else
            {
                this.Panel1.Visible = false;
            }

        }



        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            Bind(Convert.ToInt32(Application["webid"]));
        }
    }
}